home *** CD-ROM | disk | FTP | other *** search
- unit IntfPropTest;
-
- interface
-
- uses
- {$ifdef MSWindows}
- Windows, Messages, SysUtils, Classes;
- {$endif}
- {$ifdef Linux}
- SysUtils, Classes;
- {$endif}
-
- type
- IMyInterface = interface(IInterface)
- ['{329F5DD8-697B-46E2-9ABD-07BD7F439C73}']
- procedure DoSomething;
- end;
-
- TIntfImplementor = class(TComponent, IMyInterface)
- protected
- procedure DoSomething;
- end;
-
- TIntfPropTest = class(TComponent)
- private
- FIntfProp: IMyInterface;
- protected
- procedure SetIntfProp(Value: IMyInterface);
- public
- procedure Notification(AComponent: TComponent; Operation: TOperation); override;
- published
- property IntfProp: IMyInterface read FIntfProp write SetIntfProp;
- end;
-
- procedure Register;
-
- implementation
-
- uses
- {$ifdef MSWindows}
- Dialogs;
- {$endif}
- {$ifdef Linux}
- QDialogs;
- {$endif}
-
- procedure Register;
- begin
- RegisterComponents('Clinic', [TIntfPropTest, TIntfImplementor]);
- end;
-
- { TIntfPropTest }
-
- procedure TIntfPropTest.Notification(AComponent: TComponent;
- Operation: TOperation);
- begin
- inherited;
- if Assigned(IntfProp) and AComponent.IsImplementorOf(IntfProp) then
- IntfProp := nil;
- end;
-
- procedure TIntfPropTest.SetIntfProp(Value: IMyInterface);
- begin
- ReferenceInterface(FIntfProp, opRemove);
- FIntfProp := Value;
- ReferenceInterface(FIntfProp, opInsert);
- end;
-
- { TIntfImplementor }
-
- procedure TIntfImplementor.DoSomething;
- begin
- ShowMessageFmt('Doing something in a %s object', [ClassName])
- end;
-
- end.
-